"use strict";
cc._RF.push(module, '0390aX9y+RElLoFXVvAascp', 'ToolsThruster');
// scripts/ToolsThruster.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GameConstant"),
    s = cc._decorator,
    l = s.ccclass,
    c = s.property,
    d = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.spine = null, e._gameControl = null, e._nCarSite = 0, e._carTag = 0, e.nUseTime = 0, e.bCanAttack = !0, e.preCarPos = null, e;
  }

  return n(e, t), e.prototype.init = function (t, e, o, i) {
    this._gameControl = t, this._nCarSite = e, this.spine.paused = !0, this.nUseTime = 0, o == r.Collide_Car_Tag.Left ? (this.node.scaleX = 1, this.node.position = i) : (this.node.scaleX = -1, this.node.position = cc.v3(-i.x, i.y, i.z));
  }, e.prototype.onGameStart = function () {}, e.prototype.onGameOver = function () {}, e.prototype.onGameBoutReady = function () {
    this.node.active = !1, this.destroy();
  }, e.prototype.onGameBoutStart = function () {
    var t = this;
    this.bCanAttack = !0, r.Cur_Game_Type == r.Game_Type.Auto && this.scheduleOnce(function () {
      t.onUseTools();
    }, 1);
  }, e.prototype.onGameBoutOver = function () {}, e.prototype.onCanAttack = function (t) {
    this.bCanAttack = t;
  }, e.prototype.onUseTools = function (t) {
    var e = this;
    if (this.bCanAttack) return !(this.nUseTime > 0 || t && !this.isAIUseToos() || (this.nUseTime++, this.playAni(), this._gameControl.playThruster(this._nCarSite), this.scheduleOnce(function () {
      e.nUseTime--;
    }, 3), this._gameControl._weaponRightView.setUseToolsState(), 0));
  }, e.prototype.onCancelUse = function () {}, e.prototype.onDisassembly = function () {
    this.node.active = !1;
  }, e.prototype.playAni = function () {
    this.spine.paused = !1, this.spine.setAnimation(0, "animation", !1);
  }, e.prototype.isAIUseToos = function () {
    var t = this._gameControl._carRightView.getCarWorldPos();

    if (null == this.preCarPos && (this.preCarPos = t), Math.abs(t.x - this.preCarPos.x) < 100) {
      if (t.x < this._gameControl.getBoundaryWidth() + 150) return this._gameControl.onMoveRight(r.Physics_Car_Tag.Right, !0), this.preCarPos = t, !0;
      if (t.x > cc.winSize.width - this._gameControl.getBoundaryWidth() - 150) return this._gameControl.onMoveLeft(r.Physics_Car_Tag.Right, !0), this.preCarPos = t, !0;
    }

    return this.preCarPos = t, !1;
  }, a([c(sp.Skeleton)], e.prototype, "spine", void 0), a([l], e);
}(cc.Component);

o["default"] = d;

cc._RF.pop();